package md.objects;

import java.util.Random;

import md.action.GameController;
import md.constants.Constants;
import md.map.GameMap;
import md.settings.Settings;

public class EnemyWave {

	public final static Random rand = new Random();
	
	public Enemy[] enemies;
	public int enemyCount = 0;
	public int currentEnemy = 0;
	
	public int i = 0;
	
	public EnemyWave(int count) {
		init(count);
	}
	
	public final void init(int count) {
		enemies = new Enemy[count];
		for(enemyCount=0;enemyCount<count;enemyCount++)
			enemies[enemyCount] = new Enemy(GameMap.decodeX(GameMap.startPoint), 
											GameMap.decodeY(GameMap.startPoint));
	}

	public final void calculateTurn() {

		if(rand.nextInt(32) == 16)
			activateNextEnemy();
		
		for(i=0;i<enemyCount;i++)
			enemies[i].calculateTurn();
	}

	private final void activateNextEnemy() {
		if(currentEnemy < enemyCount)
			GameController.activateEnemy(enemies[currentEnemy++]);
	}
}
